import { DisbursementType } from '../../constants/disbursement-flow';

export default class Disbursement {
    id: number;
    title: string;
    currency: string;
    saved: number;
    processed: number;
    failed: number;
    failedAmount: number;
    sent: number;
    sentAmount: number;
    total: number;
    totalAmount: number;
    network: string;
    type: DisbursementType;
    doneDisbursing: boolean;

    static fromJSON = (data: {}): Disbursement => {
        const disbursement = new Disbursement();

        disbursement.id = data['id'];
        disbursement.title = data['title'];
        disbursement.currency = data['currency'];

        disbursement.saved = data['saved'];
        disbursement.processed = data['processed'];

        disbursement.failed = data['failed'];
        disbursement.failedAmount = data['failed_amount'];
        disbursement.sent = data['sent'];
        disbursement.sentAmount = data['sent_amount'];
        disbursement.total = data['total'];
        disbursement.totalAmount = data['total_amount'];
        disbursement.type = data['type'];

        disbursement.doneDisbursing = data['done_disbursing'];

        return disbursement;
    };
}
